package com.zjff.show.zjffshow.controller;

import com.zjff.show.zjffshow.entity.LoginDao;
import com.zjff.show.zjffshow.entity.ResultDao;
import com.zjff.show.zjffshow.service.LoginService;
import com.zjff.show.zjffshow.tool.JSONTool;
import com.zjff.show.zjffshow.tool.RedisTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import redis.clients.jedis.Jedis;

@RestController
@CrossOrigin
@RequestMapping("/Login/")
public class LoginController {
    @Autowired
    LoginService loginService;
    ResultDao resultDao = null;
    Jedis jedis = new RedisTool().getJedis();

    @GetMapping("/DoLogin")
    private String DoLogin(@RequestParam("UName") String UName,
                         @RequestParam("Pwd") String Pwd,
                         @RequestParam("Type") String Type){
        resultDao = new ResultDao();
        LoginDao loginDao = loginService.DoLogin(UName, Pwd, Type);
        if(loginDao != null){
            resultDao.setCode("0");
            resultDao.setMsg("登录成功");
            resultDao.setData(loginDao);
        }else{
            resultDao.setCode("1");
            resultDao.setMsg("登录失败");
        }
        return JSONTool.getJsonTool().toJson(resultDao);
    }


}
